package com.qingcheng.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.service.order.OrderService;
import com.qingcheng.service.order.OrderService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author wuchong
 * @title: OrderController
 * @projectName qingcheng_parent
 * @description: TODO
 * @date 2019.07.09下午 02:29
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Reference
    private OrderService orderService;


    private String getLoginUsername(){
        return SecurityContextHolder.getContext().getAuthentication().getName();
    }

    @GetMapping("/findOrderList")
    public List<Map<String,Object>> findOrderList(){

        String username = getLoginUsername();

        List<Map<String, Object>> orderList=orderService.findByUsername(username);

       return orderList;
    }

    @GetMapping("/findOrderListNoPay")
    public List<Map<String,Object>> findOrderLstToPay(){
        String username=getLoginUsername();
        return orderService.findOrderListToPay(username);
    }

    @GetMapping("/findOrderListToDeliver")
    public List<Map<String,Object>> findOrderListPaied(){
        String username=getLoginUsername();
        return orderService.findOrderListToDeliver(username);
    }

}
